package main

import (
	"fmt"
	"sync"
)

/*
互斥锁
*/
var x3 int64
var wg3 sync.WaitGroup
var lock sync.Mutex

func add3() {
	for i := 0; i < 5000; i++ {
		lock.Lock() // 加锁
		x3 = x3 + 1
		lock.Unlock() // 解锁
	}
	wg3.Done()
}
func main() {
	wg3.Add(2)
	go add3()
	go add3()
	wg3.Wait()
	fmt.Println(x3)
}
